Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit test for StandardMetadataServiceURLBuilder #8913

Merged
merged 3 commits into from
Sep 27, 2021

Conversation

BurningCN
Copy link
Member

What is the purpose of the change

Add unit test for StandardMetadataServiceURLBuilder

@codecov-commenter
Copy link

codecov-commenter commented Sep 24, 2021

Codecov Report

Merging #8913 (d84f229) into 3.0 (acd49fe) will decrease coverage by 0.36%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##                3.0    #8913      +/-   ##
============================================
- Coverage     63.75%   63.39%   -0.37%     
+ Complexity      315      314       -1     
============================================
  Files          1169     1180      +11     
  Lines         49226    50061     +835     
  Branches       7361     7502     +141     
============================================
+ Hits          31384    31736     +352     
- Misses        14418    14856     +438     
- Partials       3424     3469      +45     
Impacted Files Coverage Δ
...he/dubbo/common/logger/support/FailsafeLogger.java 52.80% <0.00%> (-26.47%) ⬇️
...ting/exchange/support/header/HeartbeatHandler.java 58.13% <0.00%> (-25.59%) ⬇️
.../apache/dubbo/common/context/LifecycleAdapter.java 25.00% <0.00%> (-25.00%) ⬇️
...in/java/org/apache/dubbo/config/MetricsConfig.java 78.94% <0.00%> (-21.06%) ⬇️
...ain/java/org/apache/dubbo/config/ModuleConfig.java 70.37% <0.00%> (-16.30%) ⬇️
.../remoting/transport/netty4/NettyClientHandler.java 68.96% <0.00%> (-15.52%) ⬇️
...ng/exchange/support/header/ReconnectTimerTask.java 50.00% <0.00%> (-13.64%) ⬇️
...ubbo/registry/client/AbstractServiceDiscovery.java 87.50% <0.00%> (-12.50%) ⬇️
...a/org/apache/dubbo/remoting/exchange/Response.java 87.17% <0.00%> (-7.70%) ⬇️
...rg/apache/dubbo/rpc/protocol/dubbo/DubboCodec.java 64.34% <0.00%> (-6.96%) ⬇️
... and 116 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update acd49fe...d84f229. Read the comment docs.

Copy link

@DiegoKrupitza DiegoKrupitza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All in all it looks good to me. I would suggest to write your test with Hamcrest. This will make the tests easier to read.
I suggest this since Hamcrest is already used in few tests in this project and already in the projects dependencies.

public void testBuild() {
// test generateUrlWithoutMetadata
List<URL> urls = builder.build(new DefaultServiceInstance("test", "127.0.0.1", 8080, ApplicationModel.defaultModel()));
assertEquals(1, urls.size());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use Hamcrest here to test the size in a more fluent way.
For example here you can write: assertThat(urls, hasSize(1));

In general this is not really necessary but since Hamcrest is in the project dependencies it would be nice to use it to make Testing more pleasing for the eye (easier reading and writing)

Copy link
Contributor

@changfubai changfubai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@AlbumenJ AlbumenJ merged commit cd5cad2 into apache:3.0 Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants